<script type="text/javascript">
function memProfile(member) {
	window.location='index.php?members='+member;
}
function editMemProfile(member) {
	window.location='index.php?editmem='+member;
}
function funDelMem(userId) {
	var delPro=confirm("Are you sure want to delete this member?");
    if(delPro==true) {
		var frm = document.getElementById('form1');
		document.getElementById("delMember").value=userId;
	    frm.submit();
	}	
}

</script>
<?php


if(!empty($_POST['delMember']))
{
	$memberId=$_POST['delMember'];
	$sqlDelMem="Delete from tbl_users where user_id=$memberId";
	$rstDelMem=mysql_query($sqlDelMem);	
}
?>
<form name="form1" id="form1" method="post" action="">
 <input type="hidden" name="delMember" id="delMember">
			  
<table width="100%"  border="1" cellspacing="0" class="container">
  <tr>
    <td width="469" height="25" class="tdHeader">Members  List</td>
  </tr>
  <tr>
    <td height="577">
	<br><br>
	<table width="100%"  border="0" cellspacing="0">      
      <tr class="InnerHeader">       
        <td width="16%" class="line">Member type </td>
		<td width="14%" class="line">Username </td>
        <td width="13%" class="line">First name </td>
        <td width="15%" class="line">Last name </td>
        <td width="17%" class="line">Date Regd.</td>
        <td width="8%" class="line">&nbsp;</td>
        <td width="7%" class="line">&nbsp;</td> 
		<td width="10%" class="line">&nbsp;</td>         
      </tr>
      <?php 				 
				 require_once "../includes/pagination.php";
				 $itemPerPage=15;
				 $sql_shocat="SELECT * FROM tbl_users where status!=0 AND status!=2";				 
				 $rst_shocat=mysql_query(getPagingQuery($sql_shocat,$itemPerPage));
				 $numRows = mysql_num_rows($rst_shocat);
				 if($numRows>0) {				
					 while($row_shocat = mysql_fetch_array($rst_shocat)) {				 
					 $mem_id=$row_shocat['user_id'];
					 $mem_name=$row_shocat['username'];
					 $usr_type=$row_shocat['user_type'];
					 $created_date=$row_shocat['created_date'];
					 if($usr_type==1)
						$mem_type = "Buyer";
					else if($usr_type==2)
						$mem_type = "Seller";		 
					else if($usr_type==2)
						$mem_type = "Merchant";			 
					 $mem_fname=$row_shocat['first_name'];
					 $mem_lname=$row_shocat['last_name'];
					 echo "<tr>";
					 echo "<td class='line'>".ucfirst($mem_type)."</td>";
					 echo "<td class='line'>$mem_name</td>";
					 echo "<td class='line'>$mem_fname</td>";
					 echo "<td class='line'>$mem_lname</td>";
					 echo "<td class='line'>$created_date</td>";
					 echo "<td height='20' class='line'><input type='button' name='edit' value='Edit' class='button'  onclick='editMemProfile($mem_id)'></td> ";
					 echo "<td height='20' class='line'><input type='button' name='view' value='View' class='button'  onclick='memProfile($mem_id)'></td> ";
					 echo "<td height='20' class='line'><input type='button' name='delete' value='Delete' class='button'  onclick='funDelMem($mem_id)';></td> ";
					 echo "</tr>";				
					 }
				 } else {
				 	echo "<tr>
							<td colspan='8' class='line'>No Members found.</td>
						  </tr>";
				 }				 
		?>      
       </table>
	<div align="center">
		<?php		   
		   $link="members";
		   echo $disp=getPagingLink($sql_shocat,$itemPerPage,$link);							   
		?>    
	</div>
	</td>
 </tr>
</table>